package com.my.test;

//#6.14

public class Estimatepi {
    public static void main(String[] args) {
        System.out.println("i\t\tm(i)");
        System.out.println("-----------------");
        for (int i = 1; i <= 901; i+=100) {
            double estimatePi = Piestimate(i);
            System.out.printf("%d\t\t%.4f\n",i,estimatePi);
        }

    }

    public  static double Piestimate(int i) {
        double sum = 0.0;
        for (int j = 1; j <= i; j++) {
            double pi = Math.pow(-1, j+1)/(2*j-1);
            sum += pi;
        }
        return 4*sum;
    }
}

